home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / gawk / gawk213b.zoo / test / longwrds.awk < prev    next >
Text File  |  1991-06-01  |  487b  |  23 lines

  1. # From Gawk Manual modified by bug fix and removal of punctuation
  2. # Record every word which is used at least once
  3. {
  4.     for (i = 1; i <= NF; i++) {
  5.         tmp = tolower($i)
  6.         if (0 != (pos = match(tmp, /([a-z]|-)+/))) {
  7.             used[substr(tmp, pos, RLENGTH)] = 1
  8.         }
  9.     }
  10. }
  11.  
  12. #Find a number of distinct words longer than 10 characters
  13. END {
  14.     num_long_words = 0
  15.     for (x in used) {
  16.         if (length(x) > 10) {
  17.             ++num_long_words
  18.             print x
  19.         }
  20.     }
  21.     print num_long_words, "long words"
  22. }
  23.